/*
 * @Author: boyyang
 * @Date: 2022-01-14 11:04:03
 * @LastEditTime: 2022-01-14 11:24:58
 * @LastEditors: boyyang
 * @Description: 数字前填 0 几位小数
 * @FilePath: \boyyang\src\utils\decimalPlaces.ts
 */

const decimalPlaces = (num: string | number, places: string | number = 2): string | number => {
    let _num = String(num)
    if (_num.length > places) {
        return _num
    } else {
        return (Array(places).join('0') + num).slice(-places)
    }
    // if (String(num).length > places) return num
    // return (Array(places).join('0') + num).slice(-places)
}

export {
    decimalPlaces
}
